define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    /**
     * 用户身份百分比处理
     * @class
     */
    var IdentityPercent = {
        /**
         * 初始化函数
         */
        init: function () {
            // 绑定表单提交事件
            $(document).on('submit', '#add-form, #edit-form', function () {
                // 处理直推奖励百分比
                var directReward = $('#c-direct_reward').val();
                if (directReward) {
                    $('#c-direct_reward').val(parseFloat(directReward) / 100);
                }
                
                // 处理间推奖励百分比
                var indirectReward = $('#c-indirect_reward').val();
                if (indirectReward) {
                    $('#c-indirect_reward').val(parseFloat(indirectReward) / 100);
                }
                
                // 处理链下绿色积分收益百分比
                var indirectRewardCount = $('#c-indirect_reward_count').val();
                if (indirectRewardCount) {
                    $('#c-indirect_reward_count').val(parseFloat(indirectRewardCount) / 100);
                }
                
                return true;
            });
            
            // 页面加载时处理编辑页面的百分比显示
            if ($('#edit-form').length > 0) {
                var directReward = $('#c-direct_reward').val();
                if (directReward) {
                    $('#c-direct_reward').val(parseFloat(directReward) * 100);
                }
                
                var indirectReward = $('#c-indirect_reward').val();
                if (indirectReward) {
                    $('#c-indirect_reward').val(parseFloat(indirectReward) * 100);
                }
                
                // 处理链下绿色积分收益百分比
                var indirectRewardCount = $('#c-indirect_reward_count').val();
                if (indirectRewardCount) {
                    $('#c-indirect_reward_count').val(parseFloat(indirectRewardCount) * 100);
                }
            }
        }
    };
    return IdentityPercent;
});